// 引入axios文件
import axios from '@/utils/myaxios.js'

// 登录
// 按需导入：export const
export const userLogin = (data) => {
    return axios({
        method: 'post',
        url: '/login',
        data
    })
}
// 用户注册
export const userRegister = (data) => {
    return axios({
        method: 'post',
        url: '/register',
        data
    })
}
// 通过id获取用户详情
export const getUserDetail = (id) => {
    return axios({
        url: `/user/${id}`,
        // 传递自定义的请求头，这个时候需要传递用户的token进行验证
        // headers: {
        //     Authorization:localStorage.getItem('heimatoutiao_token')
        // }
    })
}
// 更新用户信息
export const updateUserInfo = (id, data) => {
    return axios({
        method: 'post',
        url: `/user_update/${id}`,
        data
    })
}
// 5.关注用户
export const followUser = (id) => {
    return axios({
        url: `/user_follows/${id}`
    })
}
// 6.取消关注用户
export const unFollowUser = (id) => {
    return axios({
        url: `/user_unfollow/${id}`
    })
}
// 7.获取用户关注列表数据
export const getUserFollows = () => {
    return axios({
        url: `/user_follows`
    })
}
// 8.获取用户收藏列表数据
export const getUserStars = () => {
    return axios({
        url: `/user_star`
    })
}